home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / D-G / Drawing Tips.cpt / Drawing Tips
Text File  |  1990-09-02  |  4KB  |  43 lines

  1.  Drawing is the most integral part of the Macintosh and making it fast is equally important. Arcade games rely on speed but what really is the fastest method? Here is an explanation of the advantages and drawbacks of 4 different ways of performing drawing. All tests were performed on a Macintosh SE with 2 megs of RAM. The image was prepared and stored beforehand and all tests reflect the time to copy (not draw) without the cursor being visible. Rates are in milliseconds and the copying command was performed 100 times. These rates where achieved by using the profiler software that comes with THINK C.
  2.  
  3.  DRAWING TO SCREEN PORT
  4.  ======================
  5.  
  6.   This method involves the creating of your own graphics port with screenBits as its portBits. You store the image in its own bitmap and copy into this graphics port when you want to attempt drawing.
  7.  
  8.  Rates:
  9.  
  10.     Min     Max     Avg
  11.     ---------------------
  12.     22561   23919   22782
  13.  
  14.   Using the approach does require you to do some extra work as in all others to maintain MF compatability. When you are not currently in the foreground and you receive an update event, this method falls short as you have no way to tell the visible region. Of course, you could always hide everything you do on suspend and bring it back on resume.
  15.  
  16.  DRAWING TO ALTERNATE SCREEN BUFFER
  17.  ==================================
  18.  
  19.   This would be the best method unfortunately the alternate screen buffer doesn't exist on a Mac II. Use it only if you need to and only if you intend to have it work on an SE or less. The rates for this is the amount of time to draw plus about 50 milliseconds to flip the bits.
  20.  
  21.  DRAWING TO A WINDOW FROM AN OFFSCREEN PORT
  22.  ==========================================
  23.  
  24.   This has by far proved itself to be the best method as far as compatability and ease of use goes. However, if not done correctly, can become disastrously slow. CopyBits() clips the bits it is copying to the visible region of the current port so DO NOT have the window as the active port when drawing. It is vital that you are in another port when copying or you will see rates that are up to 6 times slower then that of drawing to the screen port. While performing CopyBits() from the other ports rates where roughly equivalent to drawing to the screen port.
  25.   For dealing with suspend and resume events, the following method will work. If your window is active, switch to the offscreen port and draw otherwise draw into the window. Yes it is slower but it maintains MF compatability.
  26.  
  27.  USING BLOCKMOVE
  28.  ===============
  29.  
  30.   As for compatability this method can be used pretty much with safety. Unfortunately with 32 bit quickdraw some problems can arise. I find the best approach is to use BlockMove and provide an option to use CopyBits instead. This will give some users the benifit of increased speed instead of sacrificing for all. Generally it will work fine on most B/W monitors. It's nearly twice the speed of CopyBits.
  31.  
  32.  Rates:
  33.  
  34.     Min     Max     Avg
  35.     ---------------------
  36.     13782   14769   13979
  37.  
  38.   There are heavy disadvantages with this method. You must make sure you always are copying between bitmaps that have the same widths in pixels. If not, strange results will occur. You must also make sure that you never go out of the screen buffer so make sure you are copying the right sizes. This method only really easily used when performed on the entire screen. If you want to deal with small objects you must set up 2 bitmaps, one that points to the screen and has the same width as what you are copying and one that is to the source.
  39.  
  40.  
  41.   I hope that this explanation of different rates and ways of performing drawing have been helpful. If anyone would like to see code of how any of these methods are performed, E-Mail me online.
  42.  
  43.       - Patrick5